<template>
  <div class="com">
    <p>这是一个子组件</p>
    <div>
      <p>{{ msg }}</p>
      <p>
        <button @click="handelClick(user)">按钮</button>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    msg: String,
  },
  data() {
    return {
      user: {
        id: 10,
        name: "西和",
      },
    };
  },
  methods: {
    handelClick(user) {
      this.$emit("listen", user);
    },
  },
};
</script>

<style>
p {
  width: 200px;
  color: #666;
  font-size: 14px;
  margin: 10px;
  border: 1px solid #ccc;
  padding: 10px;
}
</style>